package cate.game.role.world.giftcode;

import cate.game.GameBody;
import cate.game.role.Role;
import cate.game.role.RoleDependent;
import cate.game.world.giftcode.MyGiftCodeUseHandler;
import easy.java.dev.note.NoteField;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

public class MyGiftCode extends RoleDependent {

    @Getter
    @NoteField(value = "已经领取过的激活码", detail = "Map<激活码, 领取时间戳>")
    private Map<String, Long> codeGot;

    @Getter
    @NoteField(value = "已领取过的种类", detail = "Map<激活码, 数量>")
    private Map<String, Integer> kindGot;

    @Override
    public void initialize(Role role) {
        super.initialize(role);
        if(codeGot == null) {
            codeGot = new HashMap<>();
        }
        if(kindGot == null) {
            kindGot = new HashMap<>();
        }
    }

    public void useCode(String code) {
        new MyGiftCodeUseHandler(role).use(code);
    }

    /** 撤销礼包码使用记录 */
    public void cancelCodeUseHistory(String code) {
        this.codeGot.remove(code);
    }

}
